﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.TaskEngine.DomainModel
{
    [ContractClass(typeof(TaskActingManagerContract))]
    public interface ITaskActingManager
    {
        #region Task Actions Methods

        void ExecuteTaskAction(long applicationId, long userId, long actionId, long taskId, string comment, 
            long? actionAssignTo, Dictionary<string, object> inputs);

        #endregion
    }

    [ContractClassFor(typeof(ITaskActingManager))]
    internal abstract class TaskActingManagerContract : ITaskActingManager
    {
        public void ExecuteTaskAction(long applicationId, long userId, long actionId, long taskId, string comment, long? actionAssignTo, Dictionary<string, object> inputs)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(actionId > 0, "actionId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(taskId > 0, "taskId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(
                !actionAssignTo.HasValue || (actionAssignTo.HasValue && actionAssignTo.Value > 0),
                "actionAssignTo must be null or when has value it must be valid positive numeric value.");
        }
    }
}
